package com.neusoft.movie.v_movies.activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.neusoft.movie.v_movies.R;
import com.neusoft.movie.v_movies.adpater.ColUsersListAdapter;
import com.neusoft.movie.v_movies.common.Constants;
import com.neusoft.movie.v_movies.javabean.UsersBean;
import com.neusoft.movie.v_movies.listener.RetrofitListener;
import com.neusoft.movie.v_movies.model.UsersModel;

import java.util.List;

public class MyColUsersActivity extends BaseActivity implements RetrofitListener {

    private RecyclerView recyclerView;
    private ImageView left;
    private int u_id,collect_flag,author_id;
    private Context mContext;
    private LinearLayout button_author_all_art;


    @Override
    void initEvents() {

        left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

    }

    @Override
    void initViews() {
        setLayout(R.layout.activity_my_col_users);

        left=(ImageView) findViewById(R.id.left_button);
        button_author_all_art=(LinearLayout) findViewById(R.id.button_author_all_art);
        recyclerView = (RecyclerView) findViewById(R.id.col_user_list);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

    }

    @Override
    void initData() {
        SharedPreferences sharedPreferences=getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        u_id=sharedPreferences.getInt("u_id",0);

        mycolusers();
    }

    void mycolusers()
    {
        UsersModel usersModel = new UsersModel();
        usersModel.mycolusers(u_id,2,this);
    }

    @Override
    public void onSuccess(Object o, int flag) {
        switch (flag) {
            case Constants.MYCOLLECTUSERS:
                List<UsersBean> list = (List<UsersBean>) o;
                ColUsersListAdapter adapter = new ColUsersListAdapter(this, list);
                recyclerView.setAdapter(adapter);
                break;
        }
    }
    @Override
    public void onFailed() {
        Toast.makeText(MyColUsersActivity.this, "您还没有收藏的用户", Toast.LENGTH_SHORT).show();
    }

}
